//
//  UserSetting.m
//  FreeSWITCH_Console
//
//  Created by Christopher Danielson on 4/6/09.
//  Copyright 2009 MaxPowerSoft, LLC. All rights reserved.
//

#import "UserSetting.h"

@implementation UserSetting

@synthesize number, name, host, port, password;

-(id)initWithName:(NSString *)n host:(NSString *)h port:(NSInteger)p password:(NSString *)pass {
	self.number = 0;
	self.name = n;
	self.host = h;
	self.port = p;
	self.password = pass;
	return self;
}

-(void)dealloc{
	[name release];
	[host release];
	[password release];	
	[super dealloc];
}

#pragma mark NSCoding
- (void)encodeWithCoder:(NSCoder *)coder
{
	[coder encodeInt:self.number forKey:kUserSettingNumberKey];
	[coder encodeObject:self.name forKey:kUserSettingNameKey];
	[coder encodeObject:self.host forKey:kUserSettingHostKey];
	[coder encodeInt:self.port forKey:kUserSettingPortKey];
	[coder encodeObject:self.password forKey:kUserSettingPasswordKey];
	
}
- (id)initWithCoder:(NSCoder *)coder
{
	if (self = [super init])
	{
		self.number = [coder decodeIntForKey:kUserSettingNumberKey];
		self.name = [coder decodeObjectForKey:kUserSettingNameKey];
		self.host = [coder decodeObjectForKey:kUserSettingHostKey];
		self.port = [coder decodeIntForKey:kUserSettingPortKey];
		self.password = [coder decodeObjectForKey:kUserSettingPasswordKey];
	}
    return self;
}

#pragma mark NSCopying
- (id)copyWithZone:(NSZone *)zone {
	UserSetting *copy = [[[self class] allocWithZone:zone] init];
	copy.name = [[self.name copy] autorelease];
	copy.host = [[self.host copy] autorelease];
	copy.port = self.port;
	copy.password = [[self.password copy] autorelease];
	return copy;
}

@end
